#ifndef adc_h
#define adc_h

////////////////////////////////////////////////////
//
//	 ADC MODULE
//
////////////////////////////////////////////////////
	
	
//---------------Defines------------------------//
	
	#define FOSCDIV2 0b11000000		// Fosc/2
	#define ADCCONVSTAT 0b0000010		//
	#define ADCMODSTAT 0b00000001		//
	#define ADCRESSEL 0b10000000 		// ADC Result Select
	#define FOSCDIVFACTOR2 0b01000000 	// ADC Clock / 2 switch
	#define ADCVREF 0b00110000 		// Voltage Reference
	#define ADCACQTIME 0b0011000 		// ADC Acquisition Time
//-------------------Prototypes------------------//
void adc_Init();


//--------------------Functions---------------------------//
void adc_Init()
{
	// 1. Configure the A/D module:
	// 	• Configure analog pins / voltage reference / and digital I/O (ADCON1)
	//	 • Select A/D input channel (ADCON0)
	// 	• Select A/D conversion clock (ADCON0)
	// 	• Turn on A/D module (ADCON0)
	// 2. Configure A/D interrupt (if desired):
	// 	• Clear the ADIF bit
	//	 • Set the ADIE bit
	//	 • Set the GIE bit
	// 3. Wait the required acquisition time.
	// 4. Start conversion:
	// 	• Set the GO/DONE bit (ADCON0)
	// 5. Wait for A/D conversion to complete, by either:
	// 	• Polling for the GO/DONE bit to be cleared
	// OR
	// 	• Waiting for the A/D interrupt
	// 6. Read A/D Result register (ADRES), clear the ADIF bit, if required.
	// 7. For next conversion, go to step 1 or step 2 as required. The A/D conversion time per bit is
	// defined as TAD. A minimum wait of 2TAD is required before next acquisition starts.
	
	//ADCON0 &= ~FOSCDIV2;

	
	// ADCON0 &= ~ADCCONVSTAT;
	// ADCON0 |= ADCMODSTAT;

	// ADC Result Select
	// ADCON1 &= ~ADCRESSEL;

	// ADC Clock / 2 switch
	// ADCON1 &= ~FOSCDIVFACTOR2;

	// Voltage Reference
	// ADCON1 &= ~ADCVREF;

	// ADC Port Configuration
	// ADCON1 &= ~0b00000011;	// clear last 2 bits
	// ADCON1 |= 0b00001100;	// set bits 3 and 4

	// ADC Acquisition Time
	// ADCON2 |= ADCACQTIME;
}
#endif